const mysql = require("mysql");

// 创建链接对象
const con = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "123456",
  port: "3306",
  database: "mine-blog",
});

// 开始连接
con.connect();

// 执行 sql 语句
// const sql = "select * from users;";
// const sql2 = `insert into blogs (title, content, createtime, author) values ('标题C', '内容C',1546871704408, 'zhangsan')`;
const sql3 = `update users set state='1' where state='0'`;
con.query(sql3, (err, result) => {
  if (err) {
    console.error(err);
    return;
  }
  console.error(result);
});

// 关闭链接
con.end();
